home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / util / dir / simplefind.lha / SimpleFind / ARexx / simplefind_dopus.rexx
OS/2 REXX Batch file  |  1998-01-25  |  3KB  |  101 lines

  1. /* $VER: simplefind_dopus.rexx 1.0 (25.01.98)
  2.  * Allows SimpleFind to show its results in a DOpus lister
  3.  */
  4.  
  5. options results
  6.  
  7. sfportname = 'SIMPLEFIND.1'
  8. scriptportname = 'SIMPLEFIND_DOPUS'
  9. dopusportname = 'DOPUS.1'
  10.  
  11. /* chek for Dopus */
  12.  
  13. if ~show('p',dopusportname) then do
  14.    say 'Directory Opus doesn''t run'
  15.    exit
  16.    end
  17.  
  18. /* open rexxsupport.library which gives us some functions to
  19.    handle messages */
  20.  
  21. if ~show('l','rexxsupport.library') then
  22.    call addlib('rexxsupport.library',0,-30)
  23.  
  24. /* load SimpleFind if not already done */
  25.  
  26. if ~show('p',sfportname) then do
  27.    address command 'run >NIL: <NIL: /SimpleFind guimode=showgui'
  28.    loaded=0
  29.    do for 25 while loaded=0
  30.       delay(15)
  31.       if show('p',sfportname) then loaded=1
  32.       end
  33.    if loaded=0 then exit
  34.    drop loaded
  35.    end
  36.  
  37. /* create own messageport, which SimpleFind uses to send a message
  38.    to the Script */
  39.  
  40. if ~openport( scriptportname ) then exit
  41.  
  42. address value sfportname
  43.  
  44. addnotifyport scriptportname   /* tell SimpleFind where to send the messages */
  45. dontshowresults   /* no ResultWindow Needed */
  46.  
  47. cl = 0;   /* no currentlister yet */
  48.  
  49. do until event='quit'
  50.    waitpkt(scriptportname)   /* Wait for a message, sent by SimpleFind */
  51.    packet = getpkt(scriptportname)   /* Get the message */
  52.  
  53.    if packet ~= '00000000'x then do
  54.        event = getarg(packet,0)   /* Get the message command */
  55.        reply(packet)   /* Reply the Message */
  56.  
  57.        if event = 'start searching' then do
  58.           /* prepare the lister */
  59.           address value dopusportname
  60.           lister new
  61.           cl = result
  62.           lister SET cl BUSY 1
  63.           lister EMPTY cl
  64.           lister SET cl TITLE "SimpleFind"
  65.           lister REFRESH cl FULL
  66.           end
  67.  
  68.        if event = 'ready' then do
  69.           /* fill in the lister */
  70.           address value sfportname
  71.           getmaxentries
  72.           entries = result
  73.           getmaxfullpathlen
  74.           mfpl = result
  75.           setentrypos 0
  76.  
  77.           address value dopusportname
  78.           lister SET cl NAMELENGTH mfpl
  79.  
  80.           do for entries
  81.              /* get current entry and move cursor to the next entry */
  82.              address
  83.              getentrynext
  84.  
  85.              /* add the entry to the list */
  86.              address
  87.              lister ADD cl '"'entry.name'"' entry.size "-1" entry.seconds "rwed" entry.comment
  88.              end
  89.  
  90.           lister REFRESH cl
  91.           lister SET cl BUSY 0
  92.           cl = 0
  93.           end
  94.        end
  95.    end
  96.  
  97. if show('p',sfportname) then do
  98.    address value sfportname
  99.    removenotifyport scriptportname
  100.    end
  101.